package cn.tedu.controller;/**
 * @Author 金帮嘉诚 @Date 2021-07-20 星期二 16:39
 */
/*本类用于测试*/

import cn.tedu.pojo.Car;
import cn.tedu.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 知识点
 */
@CrossOrigin
@RestController
@RequestMapping("//car")
public class CarController {
    @Autowired
    private CarService carService;

    @RequestMapping("get")
    public List<Car> get() {
        return carService.get();
    }

    @RequestMapping("getByColumns")
    public List<Car> getByColumn(Car car) {
        return carService.getByColumns(car);
    }

    //整合完之后 insert delete的结果会自动提交
    //springboot框架自动进行事务管理
    @RequestMapping("insert")
    public void insert(Car car) {
        carService.insert(car);
    }

    @RequestMapping("delete")
    public void delete(Car car) {
        carService.delete(car);
    }
    @RequestMapping("update")
    public void update(Car car){
        carService.update(car);
    }
}
